﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace School.WebPages.School
{
    public partial class TeacherInfo : System.Web.UI.Page
    {
        TechnologySchoolEntities db = new TechnologySchoolEntities();
        protected string pMenuName = string.Empty;
        protected string sMenuName = string.Empty;


        protected void Page_Load(object sender, EventArgs e)
        {
            int tid = int.Parse(Request.QueryString["tid"]);
            string category = Request.QueryString["categories"];
            string paretnCategory = Request.QueryString["parentCategory"];
            byte categoryNum = byte.Parse(category);
            byte parentCategoryNum = byte.Parse(paretnCategory);
            string type = Request.QueryString["type"];
            
            var menudata = db.SubMenu;
            
            var sMenu = menudata.FirstOrDefault(m => m.Categories == categoryNum);

            if (parentCategoryNum != 0)
            {
                if (type == "0")
                {
                    var pMenu = menudata.FirstOrDefault(m => m.Categories == parentCategoryNum);
                    hlpMenu.NavigateUrl = pMenu.LinkUrl;
                    hlpMenu.Text = pMenu.Name;
                    ltSep.Visible = true;

                    hlsMenu.NavigateUrl = sMenu.LinkUrl;
                    hlsMenu.Text = sMenu.Name;
                }
                else
                {
                    var pMenu = menudata.FirstOrDefault(m => m.Categories == 2);
                    hlpMenu.NavigateUrl = pMenu.LinkUrl;
                    hlpMenu.Text = pMenu.Name;
                }
            }
            

            var teacher = db.Teachers.FirstOrDefault(t => t.TID == tid);
            if (teacher != null)
            {
                ltlContent.Text = teacher.Info;
            }
        }
    }
}
